<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <!-- MOTW-DISABLED saved from url=(0014)about:internet -->
    <title>How to create an event handler class and add it to the Java project</title>
    <link rel="StyleSheet" href="css/ScriptingWithJava.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="css/webworks.css" type="text/css" media="all" />
    <link rel="StyleSheet" href="webworks.css" type="text/css" media="all" />
    <script type="text/javascript" language="JavaScript1.2">
      <!--
        var  WebWorksRootPath = "";
      // -->
    </script>
  </head>
  <body>
    <div style="text-align: left;">
      <table cellspacing="0" summary="">
        <tr>
          <td>
            <a href="ScriptingWithJava.23.1.html"><img src="images/prev.gif" alt="Previous" border="0" /></a>
          </td>
          <td>
            <a href="ScriptingWithJava.23.3.html"><img src="images/next.gif" alt="Next" border="0" /></a>
          </td>
        </tr>
      </table>
    </div>
    <hr align="left" />
    <blockquote>
      <h4 class="N_hth_HowToHelp"><a name="182543">How to create an event handler class and add it to the Java project</a></h4>
      <p class="b_Body"><a name="182544">This section describes the process for using the Eclipse Java development environment to create an event handler class for a scriptable BIRT element. The steps assume that the Java perspective is open and that a Java project exists in the workspace.</a></p>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">1&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="255727">Add org.eclipse.birt.report.engine_&lt;version&gt;.jar to a Java project, as described in the following steps:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">1&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="255763">In Navigator, select a Java project and choose File</a><span class="Dingbat">&rarr;</span>Properties. In Properties, select Java Build Path<span class="Dingbat">&rarr;</span>Libraries. In Java Build Path, choose Add External JARs.</div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">2&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="255769">In JAR Selection, navigate to the Eclipse /plugins directory. In a default Eclipse installation, this directory is in the following location:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="cfi2_CodeFirstIndent2"><a name="255543">&lt;ECLIPSE_INSTALL&gt;\eclipse\plugins</a></div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">3&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="315585">Select org.eclipse.birt.core_&lt;version&gt;.jar. Use control-click to select org.eclipse.birt.report.engine_&lt;version&gt;.jar. Choose Open. Java Build Path appears, as shown in </a><a href="#315594" title="How to create an event handler class and add it to the Java project">Figure&nbsp;23-1</a>. Choose OK.</div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i3_Image3"><a name="315592"><img class="Default" src="images/JavaProjectPropertiesDialog.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 23-1 The report engine JAR file in the build path" /></a></p>
      <div class="fc3_FigCall3TitleFirst">
        <b class="Bold">Figure&nbsp;23-1&nbsp;&nbsp;</b><a name="315594">The report engine JAR file in the build path</a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">2&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="257077">Select the Java project and choose File</a><span class="Dingbat">&rarr;</span>New<span class="Dingbat">&rarr;</span>Class.</div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">3&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="257081">To set up the Java class properties, perform the following steps in New Java Class:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">1&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="260496">Navigate to the folder where you want the Java source file to reside by choosing the Browse button beside Source Folder.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">2&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="260497">If the new Java class is a part of a package, type the fully qualified package name in Package.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">3&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="191234">In Name, type a name for the class.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">4&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="191235">In Modifiers, select Public.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n2_NumList2_outer" style="margin-left: 14.1732pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n2_NumList2_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023FormatGray">5&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n2_NumList2_inner"><a name="191236">Select the ROM element event adapter class to extend:</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="b3_Bullet3_outer" style="margin-left: 28.3464pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="b3_Bullet3_inner" style="width: 14.173199999999997pt; white-space: nowrap">
                <img src="Bullet.png" alt="*" border="0" width="6" height="6" />
              </div>
            </td>
            <td width="100%">
              <div class="b3_Bullet3_inner"><a name="256987">Choose the Browse button beside Superclass.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="b3_Bullet3_outer" style="margin-left: 28.3464pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="b3_Bullet3_inner" style="width: 14.173199999999997pt; white-space: nowrap">
                <img src="Bullet.png" alt="*" border="0" width="6" height="6" />
              </div>
            </td>
            <td width="100%">
              <div class="b3_Bullet3_inner"><a name="257017">In Superclass Selection, in Choose a type, type the name of the event adapter class for the ROM element. For example, for a label element, type LabelEventAdapter, as shown in </a><a href="#295509" title="How to create an event handler class and add it to the Java project">Figure&nbsp;23-2</a>.</div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i4_Image4"><a name="257021"><img class="Default" src="images/superclassSelection.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 23-2 Selecting a Superclass" /></a></p>
      <div class="fc4_FigCall4Title">
        <b class="Bold">Figure&nbsp;23-2&nbsp;&nbsp;</b><a name="295509">Selecting a Superclass</a></div>
      <div class="b3_Bullet3_outer" style="margin-left: 28.3464pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="b3_Bullet3_inner" style="width: 14.173199999999997pt; white-space: nowrap">
                <img src="Bullet.png" alt="*" border="0" width="6" height="6" />
              </div>
            </td>
            <td width="100%">
              <div class="b3_Bullet3_inner"><a name="295510">Choose OK.</a></div>
            </td>
          </tr>
        </table>
      </div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">4&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="295512">In New Java Class, select Generate comments. New Java Class appears similar to the one shown in </a><a href="#255894" title="How to create an event handler class and add it to the Java project">Figure&nbsp;23-3</a>. </div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i2_Image2"><a name="255892"><img class="Default" src="images/JavaClass.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 23-3 New Java Class final properties" /></a></p>
      <div class="fc2_FigCall2Title">
        <b class="Bold">Figure&nbsp;23-3&nbsp;&nbsp;</b><a name="255894">New Java Class final properties</a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">5&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="257151">Choose Finish. The Java editor appears, similar to the one shown in </a><a href="#210837" title="How to create an event handler class and add it to the Java project">Figure&nbsp;23-4</a>.</div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i2_Image2"><a name="182568"><img class="Default" src="images/MyLabelClass.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 23-4 The new class in the Java editor" /></a></p>
      <div class="fc2_FigCall2Title">
        <b class="Bold">Figure&nbsp;23-4&nbsp;&nbsp;</b><a name="210837">The new class in the Java editor</a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">6&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="182569">Add the event handler method for the event handler class. Import all required classes. </a><a href="#210863" title="How to create an event handler class and add it to the Java project">Figure&nbsp;23-5</a> shows the addition of an onPrepare(&nbsp;) method that sets the background color of a label to red.</div>
            </td>
          </tr>
        </table>
      </div>
      <p class="i2_Image2"><a name="188765"><img class="Default" src="images/MyLabelClass2.png" style="display: inline; float: none; left: 0.0; top: 0.0" alt="Figure 23-5 The onPrepare( ) method in the Java editor" /></a></p>
      <div class="fc2_FigCall2Title">
        <b class="Bold">Figure&nbsp;23-5&nbsp;&nbsp;</b><a name="210863">The onPrepare(&nbsp;) method in the Java editor</a></div>
      <div class="N_n1_NumList1_outer" style="margin-left: 0pt">
        <table border="0" cellspacing="0" cellpadding="0" summary="" role="presentation">
          <tr style="vertical-align: baseline">
            <td>
              <div class="N_n1_NumList1_inner" style="width: 14.1732pt; white-space: nowrap">
                <span class="zAuto_0023Format">7&nbsp;&nbsp;</span>
              </div>
            </td>
            <td width="100%">
              <div class="N_n1_NumList1_inner"><a name="257243">Choose File</a><span class="Dingbat">&rarr;</span>Save.</div>
            </td>
          </tr>
        </table>
      </div>
    </blockquote>
    <hr align="left" />
    <table align="right" summary="">
      <tr>
        <td class="WebWorks_Company_Name_Bottom">
          <a href="notices.html">(c) Copyright Actuate Corporation 2013</a>
        </td>
      </tr>
    </table>
  </body>
</html>